import 'package:flutter/material.dart';
import 'package:helloworld/login.dart';
import 'package:helloworld/pages/addDebt.dart';
import 'package:helloworld/pages/addDeposit.dart';
import 'package:helloworld/pages/addGoal.dart';
import 'package:helloworld/pages/addIncome.dart';
import 'package:helloworld/pages/addPay.dart';
import 'package:helloworld/pages/debtDetail.dart';
import 'package:helloworld/pages/depositDetail.dart';
import 'package:helloworld/pages/goalDetail.dart';
import 'package:helloworld/pages/inCome.dart';
import 'package:helloworld/pages/payDetail.dart';
import 'package:helloworld/register.dart';
import 'package:helloworld/tabs.dart';

final routes = {
  '/index': (context) => Tabs(),
  '/addDebt': (context) => AddDebt(),
  '/addDeposit': (context) => AddDeposit(),
  '/depositDetail': (context, {arguments}) =>
      DepositDetail(arguments: arguments),
  '/debtDetail': (context, {arguments}) => DebtDetail(
        arguments: arguments,
      ),
  '/payDetail': (context, {arguments}) => PayDetail(
        arguments: arguments,
      ),
  '/addPay': (context) => AddPay(),
  '/login': (context) => Login(),
  '/addGoal': (context) => AddGoal(),
  '/goalDetail': (context, {arguments}) => GoalDetail(
        arguments: arguments,
      ),
  '/addIncome': (context) => AddIncome(),
  '/inCome': (context) => InCome(),
  '/register': (context) => Register()
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
